#include <climits>
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
#define int long long 
vector<bool> a(50000, true);
vector<int> nums;
void func() {
    a[0] = false;
    a[1] = false;
    for(int i = 2; i <= 50000; i++) {
        if(a[i]) {
            nums.push_back(i);
            for(int j = i * i; j <= 50000; j+=i) {
                a[j] = false;
            }
        }
    }
}
int count_func(int x, int y) {
    if(x < 2) x = 2;
    vector<int> is_prime(y - x + 1, true);
    for(auto& e : nums) {
        if(e * e > y) break;
        int temp = max(e * e, (x + e - 1) / e * e);
        for(int j = temp; j <= y; j+=e) {
            is_prime[j - x] = false;
        }
    }
    int count = 0;
    for(int i = x; i <= y; i++) {
        if(is_prime[i - x]) {
            count++;
        }
    }
    return count;
}
signed main() {
    int count = 0;
    int x, y;
    cin >> x >> y;
    func();
    int ret = count_func(x, y);
    cout << ret << endl;
    return 0;
}